home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Applications 2002 November / SGI IRIX 6.5 Applications 2002 November.iso / dist / gateway.idb / usr / WebFace / Tasks / connect-modem.cgi.z / connect-modem.cgi
Encoding:
Text File  |  2002-06-12  |  11.0 KB  |  316 lines

  1. #!/usr/bin/perl5
  2. #
  3. # connect-modem.cgi
  4. #
  5. # Copyright 1988-1996 Silicon Graphics, Inc.
  6. # All rights reserved.
  7. #
  8. # This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  9. # the contents of this file may not be disclosed to third parties, copied or
  10. # duplicated in any form, in whole or in part, without the prior written
  11. # permission of Silicon Graphics, Inc.
  12. #
  13. # RESTRICTED RIGHTS LEGEND:
  14. # Use, duplication or disclosure by the Government is subject to restrictions
  15. # as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  16. # and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  17. # successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  18. # rights reserved under the Copyright Laws of the United States.
  19. #
  20. # $Id: connect-modem.cgi,v 1.35 1997/11/17 19:10:43 shotes Exp $
  21.  
  22. require "/usr/OnRamp/lib/OnRamp.pm";
  23.  
  24. if (!$ARGV[0]) { printf("Location: %s%c%c","/tasks/Tasks.connect-start.cgi",10,10); } 
  25.  
  26. $myname = "connect-modem.cgi";
  27. $temp = "task.tmp";
  28. $action= "connect-modem.cgi?loop";
  29.  
  30. $it = "<td align=right><font size=4>";
  31. $ni = "</font></td>";
  32. $bo = "<td><font size=5><i>";
  33. $nb = "</i></font></td>";
  34.  
  35. @find_vals = ('port','modem_type','speed','phone', 'lname','lpassword','lpassword2');
  36.  
  37. &get_fields;
  38.  
  39. if ($ARGV[0] eq 'loop') { %vals = %fld; }
  40. else { &readValues; }
  41.  
  42. if ($ARGV[0] eq loop) {
  43.     &errorCheck;
  44.     &writeFile;
  45.  
  46.     $go = "/tasks/connect-end.cgi?m";
  47.     #printf("Location: %s%c%c",$go,10,10); 
  48.     print "Content-type: text/html\n\n";
  49.     print "<HTML><HEAD>";
  50.     print "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=$go\">";
  51.     print "</HEAD><BODY></BODY></HTML>";
  52.     exit 0;
  53. }
  54.  
  55. &generic;
  56.  
  57. sub readValues {
  58.     open(IN,"< $temp");
  59.     while(<IN>) {
  60.         @items = split(/=/);
  61.         foreach $arg (@find_vals) {
  62.             if ($arg eq $items[0]) { 
  63.                 if ($items[1] ne "\n") {
  64.                     $vals{$arg} = $items[1];
  65.                     chop $vals{$arg};
  66.                 }
  67.             }
  68.         }
  69.     }
  70.     close(IN);
  71. }
  72.  
  73. sub errorCheck {
  74.     &error("Phone number required.") if !$fld{'phone'};
  75.     &error("Invalid phone number.") if &check_phone($fld{'phone'});
  76.     &error("Login name required.") if !$fld{'lname'};
  77.     &error("Invalid login name.") if &check_login($fld{'lname'});
  78.     &error("Passwords not equal.") if ($fld{'lpassword'} ne $fld{'lpassword2'});
  79.     &error("Password required.") if !$fld{'lpassword'};
  80.     &error("Invalid password.") if &check_login($fld{'lpassword'});
  81. }
  82.  
  83. sub error {
  84.     $error = $_[0];
  85.     &generic;
  86.     exit 0;
  87. }
  88.     
  89. sub writeFile {
  90.     $fld{'modem_type'} =~ s/%2B/+/;
  91.     $fld{'modem_type'} =~ s/%26/&/;
  92.     $fld{'phone'} =~ s/\(//g;
  93.     $fld{'phone'} =~ s/\)//g;
  94.     $fld{'phone'} =~ s/\-//g;
  95.     $fld{'phone'} =~ s/\,//g;
  96.     $fld{'phone'} =~ s/ //g;
  97.  
  98.     undef %terms;
  99.     open(IN,"< $temp");
  100.     while(<IN>) {
  101.         @items = split(/=/);
  102.         chop $items[1];
  103.         $terms{$items[0]} = $items[1];
  104.     }
  105.     close(IN);
  106.     foreach $arg (@find_vals) {
  107.         $terms{$arg} = $fld{$arg};
  108.     }
  109.     open(OUT,"> $temp");
  110.     foreach $arg (keys(%terms)) {
  111.         print OUT "$arg=$terms{$arg}\n";
  112.     }
  113.     close(OUT);
  114. }
  115.  
  116. sub generic {
  117.     print "Content-type: text/html\n\n";
  118.     print "<html><head><title>Modem Configuration</title>\n";
  119.     print "<script language=\"JavaScript\">\n<!--\n";
  120.  
  121.     # JavaScript
  122. print "function Next()  {
  123.     form = document.modem;
  124.     if (!testPhone(form)) return;
  125.     if (!testWord(form.lname,\"login name\")) return;
  126.     if (!testWord(form.lpassword,\"login password\")) return;
  127.     setTimeout('form.submit()',0);
  128.     return;
  129. }\n";
  130. print "function Previous()  {
  131.     setTimeout('window.location=\"connect-second.cgi?m\"',0);
  132.     return;
  133. }\n";
  134. print "function testPhone(form) { 
  135.     Ctrl = form.phone;
  136.     if (Ctrl.value == \"\") { errorBox (Ctrl, \"The phone number is required.\"); return (false); } 
  137.     error = testPhoneChars(Ctrl.value);
  138.     if (error == 1) { errorBox (Ctrl, \"The phone number cannot contain spaces.\"); return (false); } 
  139.     if (error == 2) { errorBox (Ctrl, \"The phone number cannot contain \\nletters or punctuation.\"); return (false); } 
  140.     return (true);
  141. }\n";
  142. print "function testWord(Ctrl,what) { 
  143.     if (Ctrl.value == \"\") { errorBox (Ctrl, \"The \" + what + \" is required.\"); return (false); } 
  144.     error = testLoginChars(Ctrl.value);
  145.     if (error == 1) { errorBox (Ctrl, \"The \" + what + \" cannot be more \\nthan 8 characters long.\"); return (false); } 
  146.     if (error == 2) { errorBox (Ctrl, \"The \" + what + \" cannot contain the \" + illegal + \" character.\"); return (false); } 
  147.     if (error == 3) { errorBox (Ctrl, \"The \" + what + \" cannot contain spaces.\"); return (false); } 
  148.     return (true);
  149. }\n";
  150. print "function testPhoneChars(word) {
  151.     for(i = 0; i < word.length; i++) {
  152.         c = word.charAt(i);
  153.         if (c == ' ') return 1;
  154.         if (c != \'(\' && c != \')\' && c != \'-\' && c != \',\') {
  155.             num = parseInt(c);
  156.             if(isNaN(num)) return 2;
  157.         }
  158.     } return 0;
  159. }\n";
  160. print "function testLoginChars(word) {
  161.     if (word.length > 8) return 1;
  162.     loginChars = \"_-\.{}()*!~<>?|[]'&^\$\@\#`\\\";:\\\\/+=,%\";
  163.     for(j = 0; j < loginChars.length; j++) {
  164.         c = loginChars.charAt(j); 
  165.         if (word.indexOf(c, 0) != -1) { illegal = c; return 2; }
  166.     }
  167.     for (c = 0; c < word.length; c++) { if (word.charAt(c) == ' ') return 3; }
  168.     return 0;
  169. }\n";
  170. print "function errorBox (Ctrl, ErrorMessage) {
  171.     alert (ErrorMessage);  Ctrl.focus();  return;
  172. }\n";
  173.  
  174. print "//-->\n";
  175. print "</script></head>\n\n";
  176.  
  177.     print "<body bgcolor=\'c7ded4\' background=/tasks/connect-task.bg.gif>\n";
  178.  
  179.     if ($error) {
  180.         print "<font size=4 color=ff0000><b>Error: </b>$error<br></font>";
  181.     }
  182.     print "<i>$message</i>";
  183.  
  184.     print "<table width=100%>",
  185.           "<tr><th align=left><h1>Modem Configuration</h1></th>\n",
  186.           "<th align=right><a href=\"/newsplash.shtml\">",
  187.           "<img height=55 width=57 border=0 src=/tasks/home.gif></a>\n",
  188.           "  <a href=\"/tasks/Tasks.shtml\">",
  189.           "<img height=55 width=57 border=0 src=/tasks/back.gif></a>",
  190.           "</tr></table>\n";
  191.  
  192.     printf("\n<form name=\"modem\" action=\"%s\" method=post>\n", $action);
  193.     
  194.     print "<center><table width=620>";
  195.  
  196.     print "<tr>$bo Port where your modem is attached: $nb \n$it\n", 
  197.           &select("port",$vals{'port'},"Port 1","Port 2"), 
  198.           "$ni </tr>\n";
  199.     print "    <tr><td colspan=2>
  200.     The Internet Gateway contains two serial ports where you can attach a 
  201.     modem; they are designated as Port 1 and Port 2. In most cases, Port 1 
  202.     is reserved for connecting a display console to the server (described 
  203.     in the <CITE>WebFORCE Internet Gateway Installation Guide</CITE>). 
  204.     However, you can configure either port for the modem connection to your
  205.     Internet service provider if the port is unused. See <EM>IRIX Admin: 
  206.     Peripheral Devices</EM> for instructions on installing your modem.
  207.     </td></tr><tr><td> </td></tr>\n\n";
  208.  
  209.     if (!$vals{'modem_type'}) { $vals{'modem_type'} = 'Hayes smartmodem'; }
  210.     print "<tr>$bo Model of your modem: $nb $it\n", 
  211.           &select("modem_type",$vals{'modem_type'},
  212.           'Rixon',
  213.           'Rixon penril',
  214.           'Rixon ventel',
  215.           'Rixon vadic',
  216.           'Hayes smartmodem',
  217.           'Hayes 2400',
  218.           'Hayes accura',
  219.           'Telebit TB+',
  220.           'Telebit T2000',
  221.           'Telebit T2500',
  222.           'Telebit T1600',
  223.           'Telebit QBlazer',
  224.           'Digicom 9624LE+',
  225.           'Digicom Scout+',
  226.           'ZyXEL U-1496',
  227.           'Intel 14.4EX',
  228.           'Dallas Fax 14.4E',
  229.           'USR Sportster 14.4',
  230.           'USR Courier',
  231.           'AT&T Paradyne',
  232.           'Multitech ZDX'), 
  233.           "$ni </tr>\n";
  234.     print "    <tr><td colspan=2>
  235.     A modem converts the digital communication that a computer issues to an
  236.     analog tone sequence that can be sent over a telephone line to your 
  237.     Internet service provider. Most popular modem models are compatible 
  238.     with the Internet Gateway. Select the name of your modem model from 
  239.     the options menu.
  240.     </td></tr><tr><td> </td></tr>\n\n";
  241.  
  242.     if (!$vals{'speed'}) { $vals{'speed'} = '28800'; }
  243.     print "<tr>$bo Baud rate setting for your modem: $nb $it\n", 
  244.           &select("speed",$vals{'speed'},
  245.           '1200',
  246.           '2400',
  247.           '9600',
  248.           '14400',
  249.           '19200',
  250.           '28800',
  251.           '38400'), 
  252.           "$ni </tr>\n";
  253.     print "    <tr><td colspan=2>
  254.     The baud rate is the speed at which information is transferred between 
  255.     the Internet Gateway and your Internet service provider.  This is 
  256.     usually specified on the modem.
  257.     </td></tr><tr><td> </td></tr>\n\n";
  258.  
  259.     print "</table></center>\n";
  260.     print "<center><table width=620>";
  261.  
  262.     print "<tr>$bo Phone number for your ISP: $nb $it\n", 
  263.           &text("phone",$vals{'phone'},15), 
  264.           "$ni </tr>\n";
  265.     print "    <tr><td colspan=2>
  266.     To connect to the Internet, the Internet Gateway places a call over
  267.     the modem line to a host at the service provider's site. This phone 
  268.     number is required to reach the host, just as a phone number is 
  269.     required for a standard voice call. (Your Internet service provider 
  270.     issues this phone number.) Do not include any punctuation symbols 
  271.     or spaces with the number.
  272.     </td></tr><tr><td> </td></tr>\n\n";
  273.  
  274.     print "<tr>$bo Login name for your account on \nthe ISP host: $nb $it", 
  275.           &text("lname",$vals{'lname'},15), 
  276.           "$ni </tr>\n";
  277.     print "    <tr><td colspan=2>
  278.     The Internet Gateway automatically places a login name in calls to the 
  279.     service provider's host. The service provider host uses the name to 
  280.     associate the call with an authorized subscriber account. (Your Internet 
  281.     service provider issues the login name for your modem account.)
  282.     </td></tr><tr><td> </td></tr>\n\n";
  283.  
  284.     print "<tr>$bo Login password for your account on \nthe ISP host: $nb $it", 
  285.           "<input type=\"password\" name=\"lpassword\" value=\"$vals{'lpassword'}\" size=15>",
  286.           "$ni </tr>";
  287.  
  288.     print "<tr>$bo Again: $nb $it ", 
  289.           "<input type=\"password\" name=\"lpassword2\" value=\"$vals{'lpassword2'}\" size=15>",
  290.           "$ni </tr>";
  291.  
  292.     print "    <tr><td colspan=2>
  293.     This is the password on the account into the Internet service provider
  294.     system.  This should have been given to you by your Internet service
  295.     provider.
  296.     </td></tr><tr><td> </td></tr>\n";
  297.     print "</table></center>\n";
  298.  
  299.     print '<MAP NAME="js_map1">',
  300.     '    <AREA SHAPE="rect" COORDS="0,0,59,52" HREF="javascript:Previous()"
  301.     onMouseOver="window.status=\'\';return true">',
  302.     '</MAP>';
  303.     print "\n";
  304.     print '<MAP NAME="js_map2">',
  305.     '    <AREA SHAPE="rect" COORDS="0,0,59,52" HREF="javascript:Next()"
  306.     onMouseOver="window.status=\'\';return true">',
  307.     '</MAP>';
  308.     print "\n";
  309.     print '<IMG SRC="/tasks/rightarrow.gif" BORDER=0 USEMAP="#js_map2" align="right">';
  310.     print "\n";
  311.     print '<IMG SRC="/tasks/leftarrow.gif" BORDER=0 USEMAP="#js_map1" align="right">';
  312.  
  313.     print "\n</form></body></html>";
  314. }
  315.  
  316.